#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;

int main() {
	srand( (unsigned)time( NULL ) );

	while (1) {
		int n = rand() % 1000 + 1;
		int foo, bar = 0;

		cout << "I have a number between 1 and 1000.\n" 
			 << "Can you guess my number? ";

		while (1) {
			cin >> foo;
			bar++;
			if (foo == n) {
				cout<< "Excellent! You guessed the number!\n";

				if (bar<10) cout<< "Either you know the secret or you got lucky!\n";
				else if (bar = 10) cout << "Ahak!You know the secret.\n";
				else cout << "You should be able to do better!";
				cout << "Would you like to play again (y or n)? " << endl;

				char c;
				cin >> c;
				if (c == 'n')
					return 0;
				else 
					break;
			} else {
				if (foo < n) cout <<"Too low. Try again." << endl;
				else cout << "Too high. Try again." << endl;
				continue;
			}
		}
	}

	return 0;
}




